<template>
	<view class="goods-price">
		<view v-if="active===-1"><text class="money">￥</text>{{price}}</view>
		<view v-else><text class="money">￥</text>{{types[active].price}}</view>
	</view>
</template>

<script>
	export default {
		name: "goods-price",
		props: {
			types: {
				type: [Array, Object]
			},
			active: {
				type: Number,
				default: -1
			}
		},
		data() {
			return {
				price: ''
			};
		},
		watch: {
			types(newVal) {
				let price = newVal[0].price + '.00';
				if (newVal.length > 1) {
					price = `${price} - ${newVal[newVal.length-1].price}.00`;
				}
				this.price = price;

			}
		}
	}
</script>

<style lang="scss">
	.goods-price {
		color: $my-tawny;
		font-size: 20px;
		font-weight: 700;

		.money {
			font-size: 16px;
		}
	}
</style>
